////////////////////////////////////////////////
// -- DepthHUD Lite                           //
// by Hurricaaane (Ha3)                       //
//                                            //
// http://www.youtube.com/user/Hurricaaane    //
//--------------------------------------------//
// Skin                                       //
////////////////////////////////////////////////

local surface = surface
local draw = draw
local Color = Color

local SKIN = {}
SKIN.PrintName 		= ""
SKIN.Author 		= ""
SKIN.DermaVersion	= 1

SKIN.iBorder = 4

SKIN.cBackground = Color(0, 0, 0, 128)
SKIN.cNormal = Color(192, 255, 0, 192)
SKIN.cBad    = Color(192, 255, 0, 192)

function SKIN:_CalcRoundedSize( iMinSide )
	return math.floor(iMinSide / 16) * 2
	
end

function SKIN:_EvaluateBGAlpha( panel )
	self.cBackground.a = 128
	
end

function SKIN:PaintHPanel( panel )
	self:_EvaluateBGAlpha( panel )
	local lx, ly = panel:GetSize()
	draw.RoundedBox( 4, 0, 0, lx, ly, self.cBackground )
	
end

function SKIN:PaintHIndicator( panel )
	local lx, ly = panel:GetSize()
	local bLxIsMin = lx <= ly
	local bLyIsMin = lx >= ly
	local fRate = panel:GetRate()
	local fRevRate = 1 - panel:GetRate()
	local drawlx = bLyIsMin and math.Round(lx * fRate) or lx
	local drawly = bLxIsMin and math.Round(ly * fRate) or ly
	local minl = drawlx < drawly and drawlx or drawly
	draw.RoundedBox( self:_CalcRoundedSize( minl ), math.Round((lx - drawlx) / 2), math.Round((ly - drawly) / 2), drawlx, drawly, self.cNormal )
	
end

function SKIN:LayoutHLabel( panel )
	
end

function SKIN:LayoutHIndicatorLabel( panel )
	local px, py = panel.e_vIndicator:GetParent():GetSize()
	panel.e_vIndicator:SetSize( py - self.iBorder * 2, py - self.iBorder * 2 )
	panel.e_vIndicator:AlignLeft( self.iBorder )
	panel.e_vIndicator:CenterVertical()
	
	panel.e_vMainLabel:SetSize( panel:GetWide() - self.iBorder * 3, py - self.iBorder * 2 )
	panel.e_vMainLabel:AlignRight( self.iBorder )
	panel.e_vMainLabel:CenterVertical()
	
	print( "LLOL" )
	
	
	//debug check what true means as a parameter to invalidate layout and where exactly it should be used
	//panel.e_vIndicator:InvalidateLayout( true )
	
end

derma.DefineSkin( "DHLITE_Skin", "", SKIN )
